package lab03.test03;

import java.io.*;

public class Test03 {

    public static void main(String[] args) {

        String path = "E:\\test.txt";
        File file = new File(path);

        FileOutputStream fileOutputStream = null;
        FileInputStream fileInputStream = null;
        try {

            fileOutputStream = new FileOutputStream(file);
            fileOutputStream.write(new String("Beijing欢迎你！").getBytes());

            fileInputStream = new FileInputStream(file);
            int current;

            while ((current = fileInputStream.read()) != -1) {

                System.out.print((char) current);
            }

            fileOutputStream.write(new String("我的学号是：1606101014").getBytes());


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileInputStream.close();
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
